<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>DHTML Tree samples. dhtmlXTree - Operations with dynamic tree</title>
</head>
<style>
	body {font-size:12px}
	.{font-family:arial;font-size:12px}
	h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
</style>
<body>
	<h1>Operations with dynamic tree</h1>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<script  src="../js/dhtmlXCommon.js"></script>
	<script  src="../js/dhtmlXTree.js"></script>
	<script  src="../js/dhtmlXTree_xw.js"></script>
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
			</td>
			<td rowspan="2" style="padding-left:25" valign="top">
			Move selected <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'up')"> Up </a> | <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'down')">Down</a> | <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'left')"> Left</a>
            <br/>
            <div>
            <a  href="javascript:void(0)" onclick="tree.lockItem(tree.getSelectedItemId(),true)">Lock item</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="tree.lockItem(tree.getSelectedItemId(),false)">UnLock item</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="alert(tree.isLocked(tree.getSelectedItemId()))">Get lock state</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="trser();">Serialize</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="tree.insertNewItem(tree.getSelectedItemId(),'new','new item');">Add item</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="tree.setItemText(tree.getSelectedItemId(),'Some weird text')">Rename item</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="tree.saveOpenStates('aqa')">Save state</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="tree.loadOpenStates('aqa')">Load state</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="if (confirm('Because tree is unlimited it will never stoped, you will need to close browser or refresh it to stop process')) tree.openAllItemsDynamic()">Open all items</a></div>
            <div>
            <a  href="javascript:void(0)" onclick="tree.openItemsDynamic('0_2,0_2_3,0_2_3_1',true)">Open item 2-3-1 </a></div>
			</td>
		</tr>
		<tr>
			<td></td>
		</tr>
	</table>
<hr>
<XMP>
<div id="treeboxbox_tree" style="width:200;height:200"></div>
<script>
	tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.setImagePath("../imgs/");
		tree.loadXML("xml.php")

		...
        //expand dynamic tree
		tree.openAllItemsDynamic();
</script>
</XMP>

	<script>
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
            tree.enableDragAndDrop(true);
            tree.setXMLAutoLoadingBehaviour("id");
            //tree.setLockedIcons("close2.gif","close2.gif","close2.gif");
			tree.setOnOpenEndHandler(function(nodeId){
				alert(nodeId)
			})
            tree.setChildCalcMode("child");
            tree.setXMLAutoLoading("xml.php");
		    tree.enableSmartXMLParsing(true);
			
			tree.loadXML("xml.php");
            function trser(){
                var out=tree.serializeTree();
                out=out.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\&lt\;item/g,"<br>&lt;item");
                document.getElementById("out_zone").innerHTML=out;
            }
	</script>
<br><br>
  <div id="out_zone"></div>
</body>
</html>
